using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XFGameFramework;
using UnityEngine.UI;
using UnityEngine.Events;
public class TipPanel : Panel
{


    #region 字段
    [SerializeField] private Text text_title;
    [SerializeField] private Text text_content;
    [SerializeField] private Button btn_confirm;
    [SerializeField] private Text text_btn_confirm;
    [SerializeField] private Button btn_close;
    [SerializeField] private Text text_btn_close;

    private void Reset()
    {
        text_title = transform.Find("text_title").GetComponent<Text>();
        text_content = transform.Find("text_content").GetComponent<Text>();
        btn_confirm = transform.Find("btn_confirm").GetComponent<Button>();
        text_btn_confirm = transform.Find("btn_confirm/text_btn_confirm").GetComponent<Text>();
        btn_close = transform.Find("btn_close").GetComponent<Button>();
        text_btn_close = transform.Find("btn_close/text_btn_close").GetComponent<Text>();
    }

    #endregion


    #region 方法
    public void ShowTips(string title, 
    string content, 
    UnityAction onConfirmClick, 
    UnityAction onCloseClick = null,
    bool isShowCloseBtn = true,
     string confirm_text = "确定", 
     string close_text = "取消")//可选参数要出现在必需参数的后面
    {
        gameObject.SetActive(true);
        text_title.text = title;
        text_content.text = content;
        text_btn_confirm.text = confirm_text;
        text_btn_close.text = close_text;
        btn_confirm.onClick.RemoveAllListeners();
        btn_confirm.onClick.AddListener(onConfirmClick);
        btn_close.onClick.RemoveAllListeners();
        btn_close.onClick.AddListener(onCloseClick);

        btn_close.gameObject.SetActive(isShowCloseBtn);
    }
    #endregion
}
